<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="shortcut icon" href="img/SL.ico" type="image/x-icon">
<link href="<%=basePath%>css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="<%=basePath%>css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="<%=basePath%>css/animate.css" rel="stylesheet">
<link href="<%=basePath%>css/style.css?v=4.1.0" rel="stylesheet">
<style>
	.pag{
		margin-left:400px;
		width:500px;
		height:50px;
	}
		/* 三个按钮的颜色 */
	.btn{
		background:#395874;
	}
	.a{
		width:300px;
		height:0px;
	}
</style>
</head>
<body class="gray-bg">
 <div class="wrapper wrapper-content animated fadeInRight">
 	<div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>奖励查询</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="table_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <a href="table_basic.html#">选项1</a>
                            </li>
                            <li>
                                <a href="table_basic.html#">选项2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
				<!-- 查询按钮 -->
						<form action="<%=basePath%>UserServlet/findTuijian?pageNum=1" >
							<div class="input-group">
							<input type="text" name="user_tuijian" class="form-control" style="width:200px;margin-left:980px" placeholder="查询推荐人...">
							<span class="input-group-btn">
								<button class="btn btn-default" style="background:#395874" type="submit" >查询</button>
							</span>
							</div>
						</form>
	    <table class="table table-hover">
                        <thead>
	                        <tr>
	                        	<th><input type="checkbox" id="all" /></th>
								<th>推荐人</th>
								<th>被推荐人</th>
								<th>推荐时间</th>
								<th>奖金总额</th>
							</tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${userList}" var="user">
							<tr>
								<td><input type="checkbox" name="user_id" class="user" user_id="${user.user_id}" value="${user.user_id}"/></td>
								<td>${user.user_tuijian}</td>
								<td>${user.user_name}</td>
								<td>${user.user_time}</td>
								<td>${user.user_money}</td>
							</tr>
						</c:forEach>
                        </tbody>
                    </table>
                  
                </div>
            </div>
            <!-- 增删改三个按钮 -->
                      <div class="a pull-right" role="group" aria-label="...">
									<button type="button" class="btn btn-default"
										style="margin-left: 30px;" onclick="edit()" type="submit">修改</button>
									<button type="button" class="btn btn-default"
										style="margin-left: 30px;" onclick="del()" type="submit">删除</button>
								</div>
        </div>
		</div>
<!-- 修改模块弹窗 -->

	<div style="display: none;padding: 0px" class="" id="edit">
    <form class="" action="${pageContext.request.contextPath}/UserServlet/edit" method="post">
        <div class="control-group" style="margin:30px auto;">
            <label class="control-label" style="margin-right:13px;margin-left:50px;font-size:14px;">推荐人</label>
            <input name="user_tuijian"text" style="width:150px;height:30px;" id="user_tuijian">
        </div>
        <br>
        <div class="control-group">
            <label class="control-label" style="margin-left:50px;font-size:14px;">被推荐人</label>
            <input name="user_name" type="text" style="width:150px;height:30px;" id="user_name">
        </div>
        <div class="control-group">
            
            <input name="user_id" type="text" style="display:none" id="user_id">
        </div>
        <br>
        <div class="control-group "style="margin-top:30px;margin-left:150px;">
            <button type="submit" class="btn btn-primary" >修改</button>
        </div>
    </form>
</div>
  

		<!-- 分页页码 -->
		<div class="pag">
		
		</div>
	</div>
	
</body>
	<!-- 全局js -->
	<script src="<%=basePath%>js/jquery.min.js?v=2.1.4"></script>
	<script src="<%=basePath%>js/bootstrap.min.js?v=3.3.6"></script>
	<script src="<%=basePath%>js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script src="<%=basePath%>js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
	<script src="<%=basePath%>js/plugins/layer/layer.min.js"></script>

	<!-- 自定义js -->
	<script src="<%=basePath%>js/hplus.js?v=4.1.0"></script>
	<script src="<%=basePath%>js/contabs.js"></script>

	<!-- 第三方插件 -->
	<script src="<%=basePath%>js/plugins/pace/pace.min.js"></script>
	<script src="<%=basePath%>js/jquery-bootstrap-pagination.js"></script>
	
	<!-- 修改按钮 -->
	<script>
		function edit(){
			if($('.user:checked').length==0){
				layer.alert('请选中后再进行修改', {icon: 2});
			}else if($('.user:checked').length>1){
				layer.alert('只能选取一个进行修改', {icon: 2});
			}else{
				$.get('${pageContext.request.contextPath}/UserServlet/preEdit',
						{"user_id":$('.user:checked').attr('user_id')},function(data){
							
						var user = JSON.parse(data);
						$("#user_tuijian").attr("value",user[0].user_tuijian);
						$("#user_name").attr("value",user[0].user_name);
						$("#user_id").attr("value",user[0].user_id);
			layer.open({
					type: 1,
					content: $('#edit').html(), 
					area: ['400px', '300px'],
					shadeClose: true,
					anim: 1,
					resize: true,
					title: [' 修改推荐人', 'font-size:20px;'],
					skin: 'layui-layer-l LayerCC', 
		}
		)
		}
		)
		}
		}
	</script>
	
	<!-- 删除按钮 -->
	<script>
	function del(){
		$.get('${pageContext.request.contextPath}/UserServlet/removeById',
				$('.user').serialize(),
				function(s){
			if(s==1){
				layer.msg('删除成功',function(){
					time:500,
					location.reload();
				})
				
			}else{
				layer.alert('请选中后再进行删除 ', {icon: 2});
			}
		});
	} 
	</script>
	<script type="text/javascript">
	$(".pag").pagination({
		total_pages:${pageCount},
		current_page:${pageNum},
		next:"下一页",
		prev:"上一页",
		display_max:4,
		callback : function(event, page) {
			location = "${pageContext.request.contextPath}/UserServlet/findAllBySplit?pageNum="+page;
		}
	}) 
	</script>
	<!-- 全选按钮 -->
	<script>
		$('#all').click(function(){
			$(':checkbox').prop('checked',$(this).prop('checked'));
		})
	</script>
	
</html>